package com.taxshare.seller.controller;

import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.pvalidate.ParamValid;
import com.taxshare.response.beans.Response;
import com.taxshare.seller.service.EquipmentService;
import com.taxshare.seller.view.dto.EquipmentDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.io.UnsupportedEncodingException;

/**
 * @ClassName: EquipmentController
 * @Description:
 * @author: hjh
 * @date: 2021/6/15 14:36
 */
@RestController
@RequestMapping(value = "/equipment")
@Api(tags = "开票设备管理")
public class EquipmentController {
    @Autowired
    private EquipmentService equipmentService;

    @ApiOperation(value = "设备查询", notes = "开票设备管理")
    @PostMapping("/list")
    public Response query(@RequestBody PageRequest<EquipmentDTO> param) {
        return equipmentService.query(param);
    }

    @ApiOperation(value = "设备类型查询", notes = "开票设备管理")
    @PostMapping("/queryType")
    public Response query(@RequestBody EquipmentDTO equipmentDTO) {
        return equipmentService.query(equipmentDTO);
    }

    @ParamValid
    @ApiOperation(value = "添加开票设备信息", notes = "开票设备管理")
    @PostMapping("/add")
    public Response add(@RequestBody @Valid EquipmentDTO param) {
        return equipmentService.add(param);
    }

    @ApiOperation(value = "删除开票设备信息", notes = "开票设备管理")
    @PostMapping("/delete")
    public Response delete(@RequestParam String uuid) {
        return equipmentService.delete(uuid);
    }

    @ApiOperation(value = "启用开票设备", notes = "启用开票设备")
    @PostMapping("/updateDisable")
    public Response<String> disable(@RequestBody EquipmentDTO param) {
        return equipmentService.disable(param);
    }

    @ApiOperation(value = "修改开票设备信息", notes = "开票设备管理")
    @PostMapping("/update")
    public Response updateInfo(@RequestBody EquipmentDTO param) {
        return equipmentService.update(param);
    }

    @ApiOperation(value = "获取关联码", notes = "开票设备管理")
    @GetMapping("/getRelevanceCode")
    public Response getRelevanceCode(@RequestParam String sellerTaxNo,@RequestParam String panNo) throws UnsupportedEncodingException {
        return equipmentService.getRelevanceCode(sellerTaxNo,panNo);
    }

}


